package beans;


public class Constraint {
	private Table tab;
	private Column col;
	private String type;
	private String name;
	private String describe;
	private String condition;
	
	public Constraint (){
		tab=null;
		col=null;
		type=new String();
	}
	public Table getTab() {
		return tab;
	}
	public void setTab(Table tab) {
		this.tab = tab;
	}
	public Column getCol() {
		return col;
	}
	public void setCol(Column col) {
		this.col = col;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescribe() {
		return describe;
	}
	public void setDescribe(String describe) {
		this.describe = describe;
	}
	public String getCondition() {
		return condition;
	}
	public void setCondition(String condition) {
		if(!condition.contains("IS NOT NULL")){
			this.condition = condition;
		}else this.condition = "";
	}
	@Override
	public String toString() {
		String retour= "Constraint [" + tab + ", type=" + type
				+ ", nom=" + name  ;
		if(describe.length()!=0){
			retour+= " specifique ="+describe;
		}
		if(condition.length()!=0){
			retour+= " specifique ="+condition;
		}
		retour+= "]";
		return retour;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((col == null) ? 0 : col.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Constraint other = (Constraint) obj;
		if (col == null) {
			if (other.col != null)
				return false;
		} else if (!col.equals(other.col))
			return false;
		return true;
	}
	
	
	
}
